@extends("index")
@section("content")
<form action="/addclient" method="post" accept-charset="utf-8" class="form-inline">
    <fieldset>
        <h3 class="sub-header">仓库管理</h3>
        <div class="form-group">
            <div class="col-lg-10">
                <select id="company" class="form-control" onchange="setcompany()">
                <option value="0">入库的品牌</option>
                </select>
            </div>
        </div>
    </fieldset>
</form>
<div id="OrderTable"></div>
@stop
@section('script')
<script type="text/javascript">
$(function () {
    $("#cangku").addClass("active");
    $('.datetimepicker').datetimepicker({
        format: 'yyyy-mm-dd',
        autoclose: true,
        language:  'zh-CN',
        minView: 'month',
    });
    getcompanys();
});
function getmaxorderid () {
    $.post('getmaxorderid',{},function(res){
        if(res.Result = "OK"){
        var maxid = res.maxid;
        }
    });
}
function addorder (conpanyid) {
    $.post("/addinorder",{
    "companyid":conpanyid,
    },function(json){
    if(json.Result == "OK"){
    $('#OrderTable').jtable({
    disabled: true,
    title: '订单信息',
    actions: {
    listAction: '/getbuydetail?buyid='+json.Order.id,
    createAction: '/addbuydetail?buyid='+json.Order.id,
    updateAction: '/editebuydetail?buyid='+json.Order.id,
    deleteAction: '/deletebuydetail',
    },
    fields: {
    id: {
    key: true,
    list: false
    },
    订单号: {
    title: '订单号',
    list: false,
    create: false,
    edit: false
    },
    型号: {
    title: '车型',
    options: '/getcars'
    },
    数量: {
    title: '数量',
    },
    价格: {
    title: '售价',
    },
    }
    });
    $('#OrderTable').jtable('load');
    }
    })
}

function getcompanys () {
    $.post("/getcompanyslist",
        {},function(json) {
            $.each(json.Records,function(id,record){
                // alert(record);
                $("#company").append("<option value='"+record.id+"'>"+record.厂商名+"</option>");
            })
        })
}

function setcompany(){
    if($("#company").val()!=0){
        conpanyid = $("#company").val();
        addorder(conpanyid);
    }
}
</script>
@stop